package com.imooc.ecommerce.config;

import com.alibaba.cloud.sentinel.annotation.SentinelRestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * <p>开启服务间的调用保护, 需要给 RestTemplate 做一些包装
 *
 * @author Yaxi.Zhang
 * @since 2022/11/18 15:22
 */
@Slf4j
@Configuration
public class SentinelConfig {
    /**
     * <p>包装 RestTemplate
     */
    @Bean
    // @SentinelRestTemplate(
    //         fallback = "handleFallback", fallbackClass = RestTemplateExceptionUtil.class,
    //         blockHandler = "handleBlock", blockHandlerClass = RestTemplateExceptionUtil.class
    // )
    public RestTemplate restTemplate() {
        return new RestTemplate();  // 可以对其做一些业务相关的配置
    }

}

